package topcoder;

import java.util.Arrays;

public class TeamContestEasy {

	public int worstRank(int[] A) {
		int n = A.length;
		int t = n / 3 - 1;
		
		if (t == 0)
			return 1;
		
		int m = A[0] + A[1] + A[2] - Math.min(A[0], Math.min(A[1], A[2]));
			
		int[] B = new int[t*3];
		for (int i = 3; i < n; i++)
			B[i-3] = A[i];
		
		Arrays.sort(B);
		
		int i = t;
		int j = B.length - 1;
		int k = 1;
		
		while (i < j) {
			if (B[i] + B[j] > m) {
				k++;
				i++;
				j--;
			} else {
				i++;
			}
		}
		
		return k;
	}
}
